import request from "@/utils/request";
import type {AjaxResult,page} from "@/utils/request"

const base = '/blog/article'


export const getArticle = (data : any , params?:page) : Promise<AjaxResult> => {
    return request({
        url: `${base}/list`,
        method: 'post',
        params: {...params,reasonable : false},
        data : data
    })
}
export const getArticleInfo = (userId? : string) => {
    return request({
        url: `${base}/getArticleInfo`,
        method: 'get',
        params:{
            userId : userId
        }
    })
}


export const getRecentlyArticle = (userId? : string) => {
    return request({
        url: '/blog/article/getRecentlyArticle',
        method: 'get',
        params:{
            userId : userId
        }
    })
}
export const getArticleById = (id : string) : Promise<AjaxResult> => {
    return request({
        url: `${base}/${id}`,
        method: 'get',
    })
}

export const addArticle = (data) => {
    return request({
        url: `/blog/article/add`,
        method: 'post',
        data:data
    })
}

export const updateArticle = (data) => {
    return request({
        url: `/blog/article/update`,
        method: 'put',
        data:data
    })
}

export const detArticle = (id) => {
    return request({
        url: `/blog/article/delete/${id}`,
        method: 'delete',
    })
}




export const thumbs = (id : string) => {
    return request({
        url: `${base}/thumbs/${id}`,
        method: 'get',
    })
}

export const collection = (id : string) => {
    return request({
        url: `${base}/collection/${id}`,
        method: 'get',
    })
}

export const follow = (id : string) => {
    return request({
        url: `${base}/follow/${id}`,
        method: 'get',
    })
}
